﻿<%@ Page Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="About.aspx.cs" Inherits="Hosting.About" %>

<%@ Register TagPrefix="oajax" Namespace="OboutInc" Assembly="obout_AJAXPage" %> 

<%@ Register Assembly="obout_Interface" Namespace="Obout.Interface" TagPrefix="obout" %>

<%@ Register Assembly="obout_Window_NET" Namespace="OboutInc.Window" TagPrefix="owd" %>

<%@ Register Assembly="obout_SuperForm" Namespace="Obout.SuperForm" TagPrefix="obout" %>

<%@ Register Assembly="obout_Grid_NET" TagPrefix="obout" Namespace="Obout.Grid" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<asp:UpdatePanel ID="udp1" runat="server">
<ContentTemplate>
<div style="position: relative; z-index: 0;">
<%--About--%>
<obout:Grid id="gAbout" runat="server" AutoGenerateColumns="false" CallbackMode="true"
    DataSourceID="ldsAbout" AllowFiltering="true" Serialize="false"
    AllowColumnResizing="false"
    AllowRecordSelection="false"
    OnInsertCommand="gAbout_InsertCommand"
    OnUpdateCommand="gAbout_UpdateCommand"
    OnDeleteCommand="gAbout_DeleteCommand" PageSizeOptions="5,10,20,50" AllowManualPaging="True" AllowMultiRecordSelection="False">
<ScrollingSettings ScrollWidth="900px" />

    <Columns>
    <obout:Column DataField="ABId" HeaderText="ID" ReadOnly="true" Width="50px" />
    <obout:Column DataField="ABContent" HeaderText="Content" Visible="False" ExportAsText="true" />
    <obout:Column DataField="ABTitle" HeaderText="Title" Width="250px" />
    <obout:Column DataField="ABActive" HeaderText="Active" />
    <obout:Column AllowEdit="true" AllowDelete="true" AllowSorting="false" />
</Columns>

<ClientSideEvents OnBeforeClientEdit="gAbout_ClientEdit" OnBeforeClientAdd="gAbout_ClientAdd" 
    OnClientPopulateControls="onPopulateControls" OnBeforeClientDelete="gAbout_ClientDelete" ExposeSender="true" />
</obout:Grid>

<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="udp1">
        <ProgressTemplate>
			<div class="loading-image">
				<img src="../img/loaderWhite.gif" alt="Not image">
			</div>
        </ProgressTemplate>
    </asp:UpdateProgress>
    </div>
</ContentTemplate>
</asp:UpdatePanel>

<owd:Window ID="Window1" runat="server" IsModal="true" ShowCloseButton="true" Status="" StyleFolder="img/blue"
        MinHeight="680" MinWidth="1000" VisibleOnLoad="false" Top="0"
        Title="Add/Edit Record">

    <input type="hidden" id="ABId" runat="server" />

<div class="super-form">
<obout:SuperForm ID="sfGroupDetail Width="525" DefaultMode="Insert"
    AutoGenerateRows="false" DataKeyNames="ABId">
    
    <Fields>
        <obout:TemplateField>
            <ItemTemplate>
                <fieldset>
                <p>
                    <a href="#" id="anchorNotification"></a>
                    <div class="notification information png_bg" id="divBigNotification" style="display:none" >
	                    <div id="divNotification">
                            <label id="NotificationLabel">Update status of control.</label>
	                    </div>
                    </div>
                </p>
                <p>
                    <label for="ABTitle">Title:</label><br />
                    <input class="text-input medium-input" type="text" id="ABTitle" runat="server" />
                </p>
                <p>
                <label for="ABActive">Active:</label><br />
                    <input type="checkbox" id="ABActive" runat="server" />
                </p>
                <p>
                    <label for="ABContent">Content:</label><br />
                    <%--<obout:Editor ID="ABContent" runat="server" Height="300px" Width="100%"></obout:Editor>--%>
                    <textarea cols="100" id="editor1" name="editor1" rows="10">
                        Enter  value in here
                    </textarea>
                    <script type="text/javascript">
                        // Replace the <textarea id="editor1"> with an CKEditor instance.
                        CKEDITOR.replace('editor1', {
                            on: {
                                focus: onFocus,
                                blur: onBlur,

                                // Check for availability of corresponding plugins.
                                pluginsLoaded: function (evt) {
                                    var doc = CKEDITOR.document, ed = evt.editor;
                                    if (!ed.getCommand('bold'))
                                        doc.getById('exec-bold').hide();
                                    if (!ed.getCommand('link'))
                                        doc.getById('exec-link').hide();
                                }
                            }
                        });
                    </script>
                    <p id="eMessage"></p>
                </p>
                <p>
                    <a href="#divBigNotification">
                        <input id="Button1" type="button" class="button" value="Save Change" runat="server" onclick="saveChanges(); return false;" />
                    </a>
                    <input id="Button2" type="button" class="button" value="Cancel" runat="server" onclick="cancelChanges(); return false;" />
                </p>
                </fieldset>
            </ItemTemplate>
        </obout:TemplateField>
    </Fields>
</obout:SuperForm>

</div>

</owd:Window>

<asp:LinqDataSource EnableInsert="true" EnableDelete="true" EnableUpdate="true" ID="ldsAbout"
    ContextTypeName="Hosting.Class.HostingDomainWebsiteDataContext"
    TableName="TBL_Abouts" runat="server" />

</asp:Content>

<asp:Content ID="Content2" runat="server" ContentPlaceHolderID="HeadContent">
<script type="text/javascript" src="js/MessageValid.js"></script>    <%--Show Message--%>
<script type="text/javascript" src="js/AboutValid.js"></script>
<script type="text/javascript" src="js/ckeditor.js"></script>
<script src="js/ProcessCKEditor.js" type="text/javascript"></script>
<script type="text/javascript">

    function onPopulateControls(sender, record) {
        record.ParentID = sender.ForeignKeys.CategoryID.Value;

        return record;
    }
</script>

<style type="text/css">
        .super-form
        {
            margin: 12px;
        }
        
        .ob_fC table td
        {
            white-space: normal !important;
        }
        
        .command-row .ob_fRwF
        {
            padding-left: 50px !important;
        }
        
        #<%= UpdateProgress1.ClientID %>
    {
        position: absolute;
        z-index: 50; 
        top: 0px; 
        bottom: 0px; 
        left: -5px; 
        right: 5px; 
        width: auto; 
        height: auto;
        background-color: #EEEEEE;
        text-align: center;
        filter: alpha(opacity=60);
        -moz-opacity: 0.6;
        opacity: 0.6;
    }
        
    .loading-image
    {
        position: absolute;
        font-family: Verdana;
	    font-size: 10px;
	    color:#0C416F;
	    height: 10px;
	    top: 50%;	
	    bottom: 0px;
	    margin-top: -5px;	
	    left: 0px;
	    right: 0px;
	    margin-left: auto;
	    margin-right: auto;
	    text-align: center;
	    width: 100%;
    }
    </style>

<style type="text/css">
        .super-form
        {
            margin: 12px;
        }
        
        .ob_fC table td
        {
            white-space: normal !important;
        }
        
        .command-row .ob_fRwF
        {
            padding-left: 50px !important;
        }
    </style>

<script type="text/javascript" type="text/JavaScript">

    var detailInAddEditMode = null;

    function gAbout_ClientDelete() {
        var r = confirm("Are you sure to delete?");
        if (r == false) {
            return false;
        }
        return true;
    }

    //Get the foreign key of Master grid
    function onPopulateControls(sender, record) {

        return record;
    }

    //Action when click Add button in Detail Grid 
    function gAbout_ClientAdd(sender, record) {

        Window1.Open();
        document.getElementById("divBigNotification").style.display = "none";

        detailInAddEditMode = sender;   //Using update, insert DetailsGrid

        document.getElementById('<%= ABId.ClientID%>').value = 0;
        document.getElementById('<%= ABTitle.ClientID%>').value = "";
        document.getElementById('<%= ABActive.ClientID%>').checked = true;
        SetContents("");
        return false;
    }

    //Action when click Edit change button in Detail Grid
    function gAbout_ClientEdit(sender, record) {
        Window1.Open();

        document.getElementById("divBigNotification").style.display = "none";

        detailInAddEditMode = sender;   //Using update, insert DetailsGrid

        document.getElementById('<%= ABId.ClientID%>').value = record.ABId;
        document.getElementById('<%= ABTitle.ClientID%>').value = record.ABTitle;
        document.getElementById('<%= ABActive.ClientID%>').checked = record.ABActive.toLowerCase() == 'true' ? true : false;
        SetContents(record.ABContent);
        return false;
    }

    function saveChanges() {
        var data = new Object();

        var ABId = document.getElementById('<%= ABId.ClientID%>').value;
        data.ABTitle = document.getElementById('<%= ABTitle.ClientID%>').value;
        data.ABContent = GetContents();
        data.ABActive = document.getElementById('<%= ABActive.ClientID%>').value;

        if (ABId == 0) {
            var isValid = addValid(data.ABTitle);
            if (isValid == 1) {
                Window1.Close();
                detailInAddEditMode.executeInsert(data);
            }
            else if (isValid == 10) {
                getMessageAttention1("Title is null or empty");
            }
            else if (isValid == 11) {
                getMessageAttention1("Tittle is greater than 100");
            }
        }
        else {
            data.ABId = ABId;
            var isValid = editValid(data.ABTitle);
            if(isValid == 1) {
                Window1.Close();
                detailInAddEditMode.executeUpdate(data);
            }
            else if(isValid == 2) {
                getMessageAttention1("ID About is null or empty");
            }
            else if (isValid == 3) {
                getMessageAttention1("ID About is not valid");
            }
            else if (isValid == 10) {
                getMessageAttention1("Title is null or empty");
            }
            else if (isValid == 11) {
                getMessageAttention1("Tittle is greater than 100");
            }
        }
        setInterval(function () { hidediv('divBigNotification'); }, 4000);

    }

    function cancelChanges() {
        Window1.Close();
    }


    function hidediv(arg) {
        document.getElementById(arg).style.display = 'none';
    }

</script>

</asp:Content>

